package com.library.service;

import com.library.dao.ManagerDAO;
import com.library.model.Manager;

public class LoginService {
    private ManagerDAO managerDAO = new ManagerDAO();

    public boolean validateLogin(String managerId, String password) {
        Manager manager = managerDAO.getManagerByID(managerId);
        return manager != null && manager.getPassword().equals(password);
    }

    public boolean changePassword(String managerId, String oldPassword, String newPassword) {
        Manager manager = managerDAO.getManagerByID(managerId);
        if (manager != null && manager.getPassword().equals(oldPassword)) {
            manager.setPassword(newPassword);
            return managerDAO.updatePassword(manager);
        }
        return false;
    }
}